package dk.flashnotes.fffExample.parts {
	import dk.flashnotes.fff.page.part.APart;
	import dk.flashnotes.fff.page.part.PartData;
	import dk.flashnotes.fffExample.text.Label;
	
	import gs.TweenMax;
	import gs.easing.Back;		

	/**
	 * @author Josef Kj�rgaard
	 */
	public class DefaultTitlePart extends APart {

		private var _oTitleLabel : Label;
		private var _oTypeLabel : Label;
		private var _twTypeLabel : TweenMax;
		private var _twTitle : TweenMax;

		public function DefaultTitlePart(sPartID : String="", xmlPartData:XML=null) {
			super(sPartID, xmlPartData);
		}

		override protected function onPartCreatedAndRegisterd() : void {
			super.onPartCreatedAndRegisterd();
			createMainLabel();
		}
		
		private function createMainLabel() : void {
			_oTitleLabel = new Label(_oPage.oTN.oTNData.sTitle, 50);
			addChild(_oTitleLabel);

			_oTitleLabel.y=30;	

			_oTypeLabel = new Label(_oPage.sPageTemplateType, 12, 0.6);
			addChild(_oTypeLabel);
	
			_oTypeLabel.x = 2;
			_oTypeLabel.y = _oTitleLabel.height + _oTitleLabel.y-8;
		}

		override protected function onOpenPart() : void {
			_twTypeLabel=TweenMax.from(_oTypeLabel, 1, {x:-_oTypeLabel.width, onComplete:setPartOpned, ease:Back.easeOut});
			_twTitle=TweenMax.from(_oTitleLabel, 0.85, {x:-_oTitleLabel.width, ease:Back.easeOut});
		}

		override protected function onClosePart() : void {
			_twTypeLabel=TweenMax.to(_oTypeLabel, 0.5, {x:-_oTypeLabel.width, onComplete:setPartClosed, ease:Back.easeIn});
			_twTitle=TweenMax.to(_oTitleLabel, 0.3, {x:-_oTitleLabel.width, ease:Back.easeIn});
		}
	}
}
